package com.eusoft.book_manage.service.impl;

import com.eusoft.book_manage.entity.User;
import com.eusoft.book_manage.mapper.UserMapper;
import com.eusoft.book_manage.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 用户信息表 服务实现类
 * </p>
 *
 * @author eusoft
 * @since 2021-10-19
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public User login(User user) {
        User userDB = userMapper.login(user);
        if(userDB!=null){
            return userDB;
        }
        throw new RuntimeException("用户名/密码错误~~");
    }

    @Override
    public User getUserByAid(Integer aid) {
        User userDB = userMapper.getUserByAid(aid);
        if(userDB!=null){
            return userDB;
        }
        throw new RuntimeException("用户不存在 / 未启用");
    }
}
